home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / lang / Compiler.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  3.7 KB  |  114 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Compiler.java    1.12 98/06/29
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang;
  16.  
  17. /**
  18.  * The <code>Compiler</code> class is provided to support
  19.  * Java-to-native-code compilers and related services. By design, the
  20.  * <code>Compiler</code> class does nothing; it serves as a
  21.  * placeholder for a JIT compiler implementation.
  22.  * <p>
  23.  * When the Java Virtual Machine first starts, it determines if the
  24.  * system property <code>java.compiler</code> exists. (System
  25.  * properties are accessible through <code>getProperty</code>  and ,
  26.  * a method defined by the <code>System</code> class.) If so, it is
  27.  * assumed to be the name of a library (with a platform-dependent
  28.  * exact location and type); the <code>loadLibrary</code> method in
  29.  * class <code>System</code> is called to load that library. If this
  30.  * loading succeeds, the function named
  31.  * <code>java_lang_Compiler_start()</code> in that library is called.
  32.  * <p>
  33.  * If no compiler is available, these methods do nothing.
  34.  *
  35.  * @author  Frank Yellin
  36.  * @version 1.12, 06/29/98
  37.  * @see     java.lang.System#getProperty(java.lang.String)
  38.  * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
  39.  * @see     java.lang.System#loadLibrary(java.lang.String)
  40.  * @since   JDK1.0
  41.  */
  42. public final class Compiler  {
  43.     private Compiler() {}        // don't make instances
  44.  
  45.     private static native void initialize();
  46.  
  47.     private static native void registerNatives();
  48.  
  49.     static {
  50.         registerNatives();
  51.     String library = null;
  52.     boolean loaded = false;
  53.     try {
  54.         library = System.getProperty("java.compiler");
  55.         if ((library != null) &&
  56.         (!library.equals("NONE")) &&
  57.         (!library.equals(""))) {
  58.         System.loadLibrary(library);
  59.         initialize();
  60.         loaded = true;
  61.         }
  62.     } catch (UnsatisfiedLinkError e) {
  63.         System.err.println("Warning: JIT compiler \"" + library +
  64.                    "\" not found. Will use interpreter.");
  65.     }
  66.     String vmInfo = System.getProperty("java.vm.info");
  67.     if (loaded) {
  68.         System.setProperty("java.vm.info", vmInfo + ", " + library);
  69.     } else {
  70.         System.setProperty("java.vm.info", vmInfo + ", nojit");
  71.     }
  72.     }
  73.  
  74.     /**
  75.      * Compiles the specified class.
  76.      *
  77.      * @param   clazz   a class.
  78.      * @return  <code>true</code> if the compilation succeeded;
  79.      *          <code>false</code> if the compilation failed or no compiler
  80.      *          is available.
  81.      */
  82.     public static native boolean compileClass(Class clazz);
  83.  
  84.     /**
  85.      * Compiles all classes whose name matches the specified string.
  86.      *
  87.      * @param   string   the name of the classes to compile.
  88.      * @return  <code>true</code> if the compilation succeeded;
  89.      *          <code>false</code> if the compilation failed or no compiler
  90.      *          is available.
  91.      */
  92.     public static native boolean compileClasses(String string);
  93.  
  94.     /**
  95.      * Examines the argument type and its fields and perform some documented
  96.      * operation. No specific operations are required.
  97.      *
  98.      * @param   any   an argument.
  99.      * @return  a compiler-specific value, or <code>null</code> if no compiler
  100.      *          is available.
  101.      */
  102.     public static native Object command(Object any);
  103.  
  104.     /**
  105.      * Cause the Compiler to resume operation.
  106.      */
  107.     public static native void enable();
  108.  
  109.     /**
  110.      * Cause the Compiler to cease operation.
  111.      */
  112.     public static native void disable();
  113. }
  114.